package com.example.mycontact.DB

import android.content.ContentValues
import android.content.Context
import android.database.sqlite.SQLiteDatabase
import com.example.mycontact.bean.Contact

class ContactTable(val context: Context) {
    //打开数据库
    fun OpenDB(): SQLiteDatabase{
        val myDBHelper= MyDBHelper(context)
        val mydb=myDBHelper.writableDatabase
        return mydb
    }
    //插入新数据 添加联系人
    fun AddnewContact(newcontact: Contact): Boolean
    {
        val mydb=OpenDB()
        val values= ContentValues().apply {
            put("name",newcontact.name)
            put("phone",newcontact.tel)
            put("email",newcontact.email)
            put("address",newcontact.position)
            put("company",newcontact.company)
            put("image",newcontact.image)
        }
        return values.size()>0
    }
}